<template>
  <div class="home">
    <Post />
    <Nav />
    <List />
    <router-link to="/cart">
      <div class="btn">
      <span class="num">{{cartList.reduce((pre,ite)=>{return pre + ite.cont},0)}}</span>
      <img src="../../assets/images/cart.png" alt="">
    </div>
    </router-link>
    
  </div>
</template>

<script>
import {mapState} from "vuex"
import Post from './Post'//引入头部组件
import Nav from './Nav'//引入导航组件
import List from './List'//引入列表组件

export default {
  name: 'home',
  data: function(){
    return {
      
    }
  },
  components: {
    'Post':Post,
    'Nav':Nav,
    'List':List
  },
  computed:{
    ...mapState(["cartList"])
  }
}
</script>

<style>
  .hom {
    position: relative;
  }
  .home .btn{
    background-color: skyblue;
    position: fixed;
    bottom:20px;
    right:20px;
    width: 48px;
    height: 48px;
    border-radius:50%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .home .btn img{
    width: 60%;
    height: 60%;
  }
  .home .btn .num{
    position: absolute;
    right: 0;
    top: 0;
    background-color: red;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    color:#fff;
    text-align: center;
    line-height: 14px;
    font-size: 10px;
  }
</style>
